package com.yanliang.SqlSession;

import com.yanliang.pojo.Configuration;
import com.yanliang.pojo.MappedStatement;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

/**
 * sql 执行器 （对JDBC代码的封装）
 *
 * @Author : yanliang
 * @Data : 3/25/2020 5:41 PM
 */
public interface Executor {

    /**
     * 查询
     * @param configuration
     * @param mappedStatement
     * @param params
     * @param <E>
     * @return
     * @throws SQLException
     * @throws NoSuchFieldException
     * @throws IllegalAccessException
     * @throws IntrospectionException
     * @throws InstantiationException
     * @throws InvocationTargetException
     */
    public <E> List<E> query(Configuration configuration, MappedStatement mappedStatement, Object... params) throws SQLException, NoSuchFieldException, IllegalAccessException, IntrospectionException, InstantiationException, InvocationTargetException;

    /**
     * 更新 or 插入 or 删除，由传入的 MappedStatement 的 sqlCommandType 决定
     * @param configuration
     * @param mappedStatement
     * @param params
     * @return
     */
    public int update(Configuration configuration, MappedStatement mappedStatement, Object[] params) throws SQLException, NoSuchFieldException, IllegalAccessException;
}
